package com.gitee.wsl.compose.chart.xy.bar.model

import androidx.compose.ui.unit.Dp
import com.gitee.wsl.compose.chart.ExperimentalKoalaPlotApi

/**
 * Sealed class hierarchy to designate the label area width type and values.
 */
@ExperimentalKoalaPlotApi
 sealed class LabelWidth{
  companion object
 }

/**
 * Set the label width as a fixed [fraction] of the overall graph width. If the label is smaller
 * than the fixed fraction it will be right-justified to the graph.
 */
@ExperimentalKoalaPlotApi
data class FixedFraction(internal val fraction: Float) : LabelWidth()

@OptIn(ExperimentalKoalaPlotApi::class)
fun LabelWidth.Companion.fixed(fraction: Float) = FixedFraction(fraction)

/**
 * Set the label width as a fixed [size] in Dp. If the label is smaller than the size it will be
 * right-justified to the graph.
 */
@ExperimentalKoalaPlotApi
data class Fixed(internal val size: Dp) : LabelWidth()

@OptIn(ExperimentalKoalaPlotApi::class)
fun LabelWidth.Companion.fixed(size: Dp) = Fixed(size)

/**
 * Set the label width as a variable [fraction] of the overall graph width. If the label is smaller
 * than the fraction the graph will grow to occupy the available space.
 */
@ExperimentalKoalaPlotApi
 data class VariableFraction(internal val fraction: Float) : LabelWidth()

@OptIn(ExperimentalKoalaPlotApi::class)
fun LabelWidth.Companion.variable(fraction: Float) = VariableFraction(fraction)